package china.nanjing.mykingdom.repository;

import china.nanjing.mykingdom.object.Kingdom;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author Chen Hongyu
 */
public interface KingdomRepository extends JpaRepository<Kingdom, Long>, JpaSpecificationExecutor<Kingdom> {

    /**
     * 按名称 查找王国
     *
     * @param kingdomName 王国名
     * @return 结果
     */
    @Query(value = "select distinct kk from Kingdom as kk where kk.kingdomName like concat('%',:kingdomName,'%') ")
    Kingdom findKingdomByKingdomName(@Param(value = "kingdomName") String kingdomName);

}
